//
//  WithdrawDetailViewController.m
//  PigMarket
//
//  Created by mac on 2019/5/29.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import "WithdrawDetailViewController.h"

@interface WithdrawDetailViewController ()
/**
 bgImg
 */
@property (nonatomic , strong) UIImageView *bgImg;
/**
 icon
 */
@property (nonatomic , strong) UIImageView *icon;
/**
 succTips
 */
@property (nonatomic , strong) UILabel *succTips;
/**
 withdrawTips
 */
@property (nonatomic , strong) UILabel *withdrawTips;

/**
 金额
 */
@property (nonatomic , strong) UILabel *money;
/**
 收款账户
 */
@property (nonatomic , strong) UILabel *withdrawAccount;
/**
 btn
 */
@property (nonatomic , strong) UIButton *backBtn;
@end

@implementation WithdrawDetailViewController

#pragma mark - view life cycle
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.baseNavView.navTitleLabel.text = @"提现详情";
    self.baseNavView.leftNavBtn.hidden = YES;
    
    [self setUpView];
}


#pragma mark - init method
- (void)setUpView {
    [self initView];
    [self initLayout];
    [self initAction];
    [self initData];
}


- (void)initView {
    [self.view addSubview:self.bgImg];
    [self.bgImg addSubview:self.icon];
    [self.bgImg addSubview:self.succTips];
    [self.bgImg addSubview:self.withdrawTips];
    [self.bgImg addSubview:self.money];
    [self.bgImg addSubview:self.withdrawAccount];
    [self.view addSubview:self.backBtn];
}


- (void) initLayout {
    [self.bgImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(20 + TJ_NavBarHeight);
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
    }];
    [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.bgImg.mas_centerX);
        make.top.mas_equalTo(40);
        make.size.mas_equalTo(CGSizeMake(50, 50));
    }];
    [self.succTips mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.bgImg.mas_centerX);
        make.top.mas_equalTo(self.icon.mas_bottom).offset(25);
        make.height.mas_equalTo(22);
    }];
    [self.withdrawTips mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.bgImg.mas_centerX);
        make.top.mas_equalTo(self.succTips.mas_bottom).offset(10);
        make.width.mas_equalTo(250);
    }];
    [self.withdrawAccount mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.money.mas_left);
        make.top.mas_equalTo(self.money.mas_bottom).offset(10);
        make.height.mas_equalTo(18);
        make.bottom.mas_equalTo(-18);
    }];
    [self.money mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(92 * [JTool getScreenWidthScale]);
        make.bottom.mas_equalTo(self.withdrawAccount.mas_top).offset(-10);
        make.height.mas_equalTo(18);
    }];
    
    [self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(30);
        make.bottom.mas_equalTo(-60 * [JTool getScreenWidthScale]);
        make.right.mas_equalTo(-30);
        make.height.mas_equalTo(48 * [JTool getScreenWidthScale]);
    }];
}

- (void) initAction {
    [self.backBtn addTarget:self action:@selector(backBtnClick) forControlEvents:UIControlEventTouchUpInside];
}

- (void)initData {
    
    NSString *money = self.withdrawMoney ?self.withdrawMoney :@"0";
    self.money.text = [NSString stringWithFormat:@"提现金额：%@元",money];
    
    NSString *account = self.account ? self.account :@"";
    self.withdrawAccount.text = [NSString stringWithFormat:@"收款账户：%@", account];
}

#pragma mark - delegate

#pragma mark - target action

- (void)backBtnClick {
    
    [self.navigationController popToRootViewControllerAnimated:YES];
}

#pragma mark - getter and setter

- (UIImageView *)bgImg {
    if (!_bgImg) {
        _bgImg = [[UIImageView alloc] init];
        _bgImg.image = [UIImage imageNamed:@"user_myasset_withdrawdetail_bg"];
        _bgImg.layer.shadowColor = [UIColor colorWithRed:59/255.0 green:74/255.0 blue:116/255.0 alpha:0.35].CGColor;
        _bgImg.layer.shadowOffset = CGSizeMake(0,2);
        _bgImg.layer.shadowOpacity = 1;
        _bgImg.layer.shadowRadius = 4;
    }
    return _bgImg;
}


- (UIImageView *)icon {
    if (!_icon) {
        _icon = [[UIImageView alloc] init];
        _icon.image = [UIImage imageNamed:@"meat_complaints_selected"];
    }
    return _icon;
}


- (UILabel *)succTips {
    if (!_succTips) {
        _succTips = [[UILabel alloc] init];
        _succTips.textColor = [UIColor textBlackColor];
        _succTips.font = [UIFont systemFontOfSize:16];
        _succTips.text = @"提现申请提交成功";
    }
    return _succTips;
}


- (UILabel *)withdrawTips {
    if (!_withdrawTips) {
        _withdrawTips = [[UILabel alloc] init];
        _withdrawTips.textColor = [UIColor colorWithHexString:@"#999999"];
        _withdrawTips.font = [UIFont systemFontOfSize:13];
        _withdrawTips.numberOfLines = 0;
        _withdrawTips.textAlignment = NSTextAlignmentCenter;
        _withdrawTips.text = @"提现后24小时内到账，若未及时到账请联系豚集客服人员";
    }
    return _withdrawTips;
}


- (UILabel *)money {
    if (!_money) {
        _money = [[UILabel alloc] init];
        _money.textColor = [UIColor colorWithHexString:@"#999999"];
        _money.font = [UIFont systemFontOfSize:13];
    }
    return _money;
}


- (UILabel *)withdrawAccount {
    if (!_withdrawAccount) {
        _withdrawAccount = [[UILabel alloc] init];
        _withdrawAccount.textColor = [UIColor colorWithHexString:@"#999999"];
        _withdrawAccount.font = [UIFont systemFontOfSize:13];
    }
    return _withdrawAccount;
}


- (UIButton *)backBtn {
    if (!_backBtn) {
        _backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_backBtn setBackgroundImage:[UIImage imageNamed:@"btn_nomal_bg"] forState:UIControlStateNormal];
        [_backBtn setTitle:@"返回" forState:UIControlStateNormal];
    }
    return _backBtn;
}


@end
